package day_17.FanSheGouZao;

import java.lang.reflect.Constructor;

public class ReflectDemo1 {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException {
        //m1();
        //m2();
        //m3();
        //m4();
    }

    private static void m4() throws ClassNotFoundException, NoSuchMethodException {
        //        Constructor<T> getDeclaredConstructor(Class<?>... parameterTypes)：
//                                      返回单个构造方法对象
        //1.获取Class对象
        Class aClass = Class.forName("day_17.FanSheGouZao.Student");
        Constructor declaredConstructor = aClass.getDeclaredConstructor(String.class);
        System.out.println(declaredConstructor);
    }

    private static void m3() throws ClassNotFoundException, NoSuchMethodException {
        //        Constructor<T> getConstructor(Class<?>... parameterTypes)：
//                                      返回单个公共构造方法对象
        Class aClass = Class.forName("day_17.FanSheGouZao.Student");
        Constructor constructor = aClass.getConstructor();
        System.out.println(constructor);

        Constructor constructor1 = aClass.getConstructor(String.class,int.class);
        System.out.println(constructor1);
    }

    private static void m2() throws ClassNotFoundException {
        //        Constructor<?>[] getDeclaredConstructors()：
//                                      返回所有构造方法对象的数组
        //1.获取Class对象
        Class aClass = Class.forName("day_17.FanSheGouZao.Student");
        Constructor[] declaredConstructors = aClass.getDeclaredConstructors();
        for (Constructor declaredConstructor : declaredConstructors) {
            System.out.println(declaredConstructor);

        }
    }

    private static void m1() throws ClassNotFoundException {
        //        Constructor<?>[] getConstructors()：
//                                      返回所有公共构造方法对象的数组
        //1.获取Class对象
        Class aClass = Class.forName("day_17.FanSheGouZao.Student");
        Constructor[] constructors = aClass.getConstructors();
        for (Constructor constructor : constructors) {
            System.out.println(constructor);
        }
    }
}
class lx02{
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException {
        //m1();
        //m2();
        //m3();
        m4();
    }

    private static void m4() throws ClassNotFoundException, NoSuchMethodException {
        Class aClass = Class.forName("day_17.FanSheGouZao.Student");
        Constructor Constructor = aClass.getDeclaredConstructor(String.class);
        System.out.println(Constructor);
    }

    private static void m3() throws ClassNotFoundException, NoSuchMethodException {
        Class aClass = Class.forName("day_17.FanSheGouZao.Student");
        Constructor constructor = aClass.getConstructor();
        System.out.println(constructor);
        Constructor constructor1 = aClass.getConstructor(String.class, int.class);
        System.out.println(constructor1);
    }

    private static void m2() throws ClassNotFoundException {
        Class aClass = Class.forName("day_17.FanSheGouZao.Student");
        Constructor[] Constructors = aClass.getDeclaredConstructors();
        for (Constructor constructor : Constructors) {
            System.out.println(constructor);

        }
    }

    private static void m1() throws ClassNotFoundException {
        Class aClass = Class.forName("day_17.FanSheGouZao.Student");
        Constructor[] constructors = aClass.getConstructors();
        for (Constructor constructor : constructors) {
            System.out.println(constructor);
        }
    }
}
